package com.oocl.chat.operate.impl;

import com.oocl.chat.operate.ReceiveOperate;
import com.oocl.chat.pojo.Message;
import com.oocl.chat.ui.ChatFrame;

public class ReceiveOperateImpl implements ReceiveOperate {
	private ChatFrame chatFrame;
	
	public void receiveChat(Message message) {
		chatFrame.setMessage(message);
		chatFrame.setVisible(true);
	}

	public void receiveShake(Message message) {
		chatFrame.shake();
		chatFrame.setShakeMessage(message.getSender());
	}

	public void  receiveNotifyList(Message message) {
		chatFrame = new ChatFrame(message.getSender());
		chatFrame.setVisible(true);
		String[] users = message.getContent().split(",");
		for (String user : users) {
			if (!user.trim().equals(""))
				chatFrame.setFriend(user.trim());
		}
		chatFrame.setVisible(true);
	} 

	public void receiveOnline(Message message) {
		String sender = message.getSender();
		chatFrame.setFriend(sender);
		chatFrame.setOnlineMessage(sender);
	}

	public void receiveDownline(Message message) {
		chatFrame.delUser(message.getSender());
		chatFrame.setDownlineMessage(message.getSender());
	}

	

	
}
